#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int x=0;
	bool f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=0;
		c=getchar();
	}while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}return f?x:~(x-1);
}inline void print(int x){
	if(x>9)print(x/10);
	putchar(x%10+'0');
}const int N=1e5+5;
int T,n,m,L,V,d[N],v[N],a[N],p[N],t,ans1,ans2;
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T=read();
	while(T--){
		n=read();m=read();L=read();V=read();t=114514;ans1=ans2=0;
		for(int i=1;i<=n;i++){
			d[i]=read();v[i]=read();a[i]=read();
			if(t==114514){
				if(a[i]>=0)t=1;
				else t=2;
			}else if(t!=0){
				if(a[i]>=0 && t!=1)t=0;
				else if(a[i]<0 && t!=2)t=0;
			}
		}for(int i=1;i<=m;i++)p[i]=read();
		if(t==1){
			ans2=m;
			for(int i=1;i<=n;i++)if(d[i]<=p[m]&&V*V<v[i]*v[i]+2*a[i]*(p[m]-d[i]))ans1++;
			if(ans1!=0)ans2--;
			print(ans1);putchar(' ');
			print(ans2);putchar('\n');
		}else if(t==2){
			
		}else{
			
		}
	}
	return 0;
}
